package com.hqyj.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.yaml.snakeyaml.error.MarkedYAMLException;

import java.util.HashMap;

/**
 * 项目:demo-springboot-230701
 * 描述:
 * 时间:2023/9/26 9:20
 * 作者:admin
 * 版本:1.0
 **/
@RestControllerAdvice(basePackages = "com.hqyj.controller")
public class StudentControllerAdvice {
    /**
     * 处理MyarithmeticException自定义异常
     * @return
     */
    @ExceptionHandler(MyarithmeticException.class)
    public HashMap<String,Object> MyarithmeticException(MyarithmeticException e){
        HashMap<String,Object> map = new HashMap<String,Object>();
        map.put("code",e.getCode());
        map.put("msg",e.getMsg());
        map.put("info",e.getInfo());

       return  map;
    }
    /**
     * 处理JwtException自定义异常
     * @return
     */
    @ExceptionHandler(JwtException.class)
    public HashMap<String,Object> JwtException(JwtException e){
        HashMap<String,Object> map = new HashMap<String,Object>();
        map.put("code",e.getCode());
        map.put("msg",e.getMsg());
        map.put("info",e.getInfo());

        return  map;
    }

}
